package wangwenjun.phase3.executor.completablefuture.demo02;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.CompletableFuture;

/**
 * @author ChangLiang
 * @date 2020/10/11
 */
@Slf4j
public class ChainDataLoader extends DataLoader {

    @Override
    protected void doLoad() {
        CompletableFuture
                .runAsync(super::loadConfigurations)
                .thenRun(super::loadUsers)
                .thenRun(super::loadOrders)
                // 增加回调函数
                .whenComplete((result, throwable) -> log.info("完成时回调--加载完成"))
                // 等待完成
                .join();
    }

    public static void main(String[] args) {
        new ChainDataLoader().load();
    }
}
